#ifndef __M_INETADDR_H__
#define __M_INETADDR_H__

// 对原生sockaddr_in的封装
#include <arpa/inet.h>
#include <netinet/in.h>
#include <string>
#include <cstring>


class InetAddr {
    public:
        InetAddr(){
            memset(&_addr, 0, sizeof(_addr));
        }

        InetAddr(uint16_t port) :_port(port) {
            memset(&_addr, 0, sizeof(_addr));
            _addr.sin_family = AF_INET;
            _addr.sin_addr.s_addr = INADDR_ANY;
            _addr.sin_port = htons(_port);
        }

        socklen_t NetAddrLen()
        {
            return sizeof(_addr);
        }

        struct sockaddr* netAddrPtr() {
            return (struct sockaddr*)&_addr;
        }



    private:
        struct sockaddr_in _addr;
        std::string _ip; 
        uint16_t _port;
};

#endif